from django.shortcuts import render

# Create your views here.
from django.http import HttpResponse
from django.shortcuts import render
from django.template import loader
from django.http import Http404
from django.http import HttpResponseRedirect
from django.urls import reverse
from django.views import generic
from django.utils import timezone
from django.contrib.auth.decorators import login_required
from django.contrib.auth import authenticate, login
from django.contrib.auth import logout
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm
def index(request):
    return render(request, 'index.html')





def about(request):
    return HttpResponse(request, 'about.html')
def contact(request):
    return render(request, 'contact.html')
def cart(request):
    return render(request, 'cart.html')
def checkout(request):
    return render(request, 'checkout.html')
def shop(request):
    return HttpResponse(request, 'shop.html')
def shop_single(request):
    return render(request, 'shop-single.html')

def login_view(request):
    if request.method == 'POST':
        username = request.POST['username']
        password = request.POST['password']
        user = authenticate(request, username=username, password=password)
        if user is not None:
            login(request, user)
            return HttpResponseRedirect(reverse('index'))
        else:
            return render(request, 'login.html', {'error_message': 'Invalid login'})
    return render(request, 'login.html')
def logout_view(request):
    logout(request)
    return HttpResponseRedirect(reverse('index'))
def thankyou(request):
    return render(request, 'thankyou.html')































